package com.edu.shiro.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

@Component
public class CommonErrorPageRegistrar implements ErrorPageRegistrar {

	@Override
	public void registerErrorPages(ErrorPageRegistry registry) {
		ErrorPage Page404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404.html");
		ErrorPage Page500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/500.html");
		ErrorPage unauthPage = new ErrorPage(UnauthorizedException.class,"/unauthorized.html");
		registry.addErrorPages(Page404,Page500,unauthPage);
	}

}
